package com.customer.crm.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.customer.crm.system.mapper.MenuMapper;
import com.customer.crm.system.mapper.SystemRoleMapper;
import com.customer.crm.system.pojo.Menu;
import com.customer.crm.system.pojo.SystemRole;
import com.customer.crm.system.pojo.SystemUser;
import com.customer.crm.system.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lyp
 * @create 2021/12/16
 */

@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu>  implements MenuService {

    @Autowired
    private SystemRoleMapper systemRoleMapper;

    @Override
    public List<Menu> findMenu(SystemUser systemUser) {
        List<SystemRole> roles = systemRoleMapper.findByUserId(systemUser.getId());
        for (SystemRole role : roles) {
            String id = role.getId();
            return baseMapper.findMenu(roles , id );
        }
        return null;
    }
}
